package com.ai.api.controller;

import com.ai.api.chatGLM.ChatGLMTask;
import com.ai.bo.InterViewerBo;
import com.ai.bo.InterviewRecordBO;
import com.ai.bo.SubmitAnswerBo;
import com.ai.grace.result.GraceJSONResult;
import com.ai.service.InterviewRecordService;
import com.ai.utils.RedisOperator;
import com.ai.vo.InterviewRecordVO;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;
import wst.ai.pojo.interviewrecord.InterviewRecord;

@RestController
@RequestMapping("interviewRecord")
public class InterviewerRecordController {
    @Autowired
    private ChatGLMTask chatGLMTask;
    @Autowired
    private InterviewRecordService interviewRecordService;
    @PostMapping("collect")
    public GraceJSONResult collect(@RequestBody SubmitAnswerBo submitAnswerBo){
        chatGLMTask.display(submitAnswerBo);
        return GraceJSONResult.ok();
    }

    /**
     * 获取面试记录
     * @return
     */
    @GetMapping("list")
    public GraceJSONResult list(InterviewRecordBO interviewRecordBO){
        PageInfo<InterviewRecordVO> pageInfo = interviewRecordService.interviewRecordList(interviewRecordBO);
        return GraceJSONResult.ok(pageInfo);
    }

    /**
     * 获取面试详情
     * @param id
     * @return
     */
    @GetMapping("detail")
    public GraceJSONResult detail(String id){
        InterviewRecord interviewRecord = interviewRecordService.detail(id);
        return GraceJSONResult.ok(interviewRecord.getResult());
    }
}
